const express = require('express');
const router = express.Router();
const passport = require('passport')
const { body } = require('express-validator');
var multer = require('multer')
var upload = multer({ dest: './tmp/' })
const service = require('../service/admin')
const register = [
  body('username').isString(),
  body('password').isString()
]
router.post('/register', register, service.register)
const data = [
    body('username').isString(),
    body('password').isString()
  ]
router.post('/login', data, service.login)
router.get('/getAllUser',service.getAllUser)
router.get('/getUserName',service.getUserName)
const form = [
  body('form').isString(),
  body('data').isString(),
  body('page').isString(),
  body('size').isString()
] 
router.post('/form',form,service.adminManage)
const searchLike = [
  body('form').isString(),
  body('data').isString(),
  body('page').isString(),
  body('size').isString()
] 
router.post('/searchLike',form,service.searchLike)
router.all('/upload', upload.single('file'), service.uploadFile)
router.post('/getHeadAll',form,service.getHeadAll)
const authorinfo = [
  body('author_id').isString()
] 
router.post('/getAuthorinfo',authorinfo,service.getAuthorinfo)
const deleteArray = [
  body('form').isString(),
  body('key').isString(),
  body('data').isString()
]
router.post('/deleteArray',deleteArray,service.deleteArray)
const updateImageInfo = [
  body('data').isString(),
  body('ksample_idey').isString()
]
router.post('/updateImageInfo',updateImageInfo,service.updateImageInfo)
module.exports = router;